Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.
The set-value npm package is a utility for setting deeply nested values within an object using dot-path notation or by providing a path array. It is useful for updating values in a mutable way without directly accessing properties, especially when dealing with complex or deeply nested objects.
Set nested values using dot-path
This feature allows you to set a value at a nested path within an object using a string dot-path notation.
const setValue = require('set-value');
const obj = {};
setValue(obj, 'a.b.c', 'value');
console.log(obj); //=> { a: { b: { c: 'value' } } }
Set nested values using array-path
This feature allows you to set a value at a nested path within an object using an array to describe the path.
const setValue = require('set-value');
const obj = {};
setValue(obj, ['a', 'b', 'c'], 'value');
console.log(obj); //=> { a: { b: { c: 'value' } } }
Set multiple values
This feature allows you to set multiple values at different paths within the same object.
const setValue = require('set-value');
const obj = {};
setValue(obj, 'a.b.c', 'value1');
setValue(obj, 'x.y.z', 'value2');
console.log(obj); //=> { a: { b: { c: 'value1' } }, x: { y: { z: 'value2' } } }
lodash.set is a method from the Lodash library that performs a similar function to set-value. It allows setting values at a given path of an object tree. Lodash is a more extensive utility library, and lodash.set is just one of its many functions.
dot-prop is another npm package that allows you to get, set, or delete properties from a nested object using dot-path notation. It is similar to set-value but also provides methods for getting and deleting properties.
deepdash is an extension for Lodash that adds deep object manipulation capabilities. It provides methods for deep setting, getting, and many other operations on nested objects. It is more feature-rich compared to set-value, which focuses solely on setting values.
Create nested values and any intermediaries using dot notation (
'a.b.c'
) paths.
Install with npm:
$ npm i set-value --save
var set = require('set-value');
var obj = {};
set(obj, 'a.b.c', 'd');
console.log(obj);
//=> {a: {b: c: 'd'}}
a.b.c
) to get a nested value from an object. | homepage'a.b.c'
) paths. | homepageInstall dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Jon Schlinkert
Copyright © 2016 Jon Schlinkert Released under the MIT license.
This file was generated by verb on January 19, 2016.
FAQs
Set nested properties on an object using dot notation.
The npm package set-value receives a total of 12,226,224 weekly downloads. As such, set-value popularity was classified as popular.
We found that set-value demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.